<layout name="page" />
<block name="content">
	{:widget('page_header/simple',array($flow_type['name'].'：'.$vo['name']))}
	<div class="x-panel hidden-print">
		<div class="x-panel-body frame">
			<div class="box col-12">
				<a onclick="go_return_url();" class="btn">返回</a>
				<eq name="is_edit" value="1">
					<neq name="flow_type.is_lock" value="1">
						<a onclick="popup_confirm();"  class="btn">选择审批流程</a>
					</neq>
				</eq>
				<a href="#flow_status"  class="btn">审批情况</a>
				<notempty name="to_confirm">
					<a href="#confirm"  class="btn">审批意见</a>
				</notempty>
			</div>
			<div class="col-12 text-right">
				<a onclick="winprint();" class="btn  hidden-xs">打印</a>
				<eq name="vo.step" value="40">
					<a onclick="popup_refer();" class="btn">传阅</a>
				</eq>
				<eq name="is_edit" value="1">
					<a id="btn_save" class="btn" onclick="save();">保存</a>
				</eq>
			</div>
		</div>
	</div>
	<!--审批人可编辑模板  -->
	<eq name="is_edit" value="1">
		<div class="frame">
			<form method='post' id="form_data" name="form_data" enctype="multipart/form-data" >
				<input type="hidden" id="id" name="id" value="{$vo.id}">
				<input type="hidden" id="step" name="step" value="{$vo.step}">
				<input type="hidden" id="ajax" name="ajax" value="0">
				<input type="hidden" id="type" name="type" value="{$flow_type.id}">
				<input type="hidden" id="opmode" name="opmode" value="edit">
				<input type="hidden" id="confirm" name="confirm" value="">
				<input type="hidden" id="confirm_name" name="confirm_name" value="">
				<input type="hidden" id="consult" name="consult" value="">
				<input type="hidden" id="consult_name" name="consult_name" value="">
				<input type="hidden" id="refer" name="refer" value="">
				<input type="hidden" id="refer_name" name="refer_name" value="">
				<div class="frame">
					<div class="box col-12">
						
							<label class="input-label" for="name">标题1*：</label>
							
								<input value="{$vo.name}" class="input" type="text" id="name" name="name" check="required" info="请输入标题">
							</div>
						</div>
					</div>
				</div>
				<div class="frame">
					<div class="box col-12">
						
							<label class="input-label" >文件编号*：</label>
							
								<p class="input-static">
									{$flow_type.doc_no_format}
								</p>
							</div>
						</div>
					</div>
					<div class="box col-12">
						
							<label class="input-label" >日期：</label>
							
								<p class="input-static">
									{$vo.create_time|to_date='Y-m-d h:i'}
								</p>
							</div>
						</div>
					</div>
				</div>
				<div class="frame">
					<div class="box col-12">
						
							<label class="input-label" >编写人：</label>
							
								<p class="input-static">
									{$vo.user_name}
								</p>
							</div>
						</div>
					</div>
					<div class="box col-12">
						
							<label class="input-label" >部门：</label>
							
								<p class="input-static">
									{$vo.dept_name}
								</p>
							</div>
						</div>
					</div>
				</div>
				<div class="frame">
					<div class="box col-12">
						
							<label class="input-label" >审批：</label>
							<div class="input-block address_list_box">
								<p id="confirm_wrap" class="input-static address_list">
									{$vo.confirm_name}
								</p>
							</div>
						</div>
					</div>
					<div class="box col-12">
						
							<label class="input-label" >协商：</label>
							<div class="input-block address_list_box">
								<p id="consult_wrap" class="input-static address_list">
									{$vo.consult_name}
								</p>
							</div>
						</div>
					</div>
					<div class="box col-12">
						<div class="layui-form-item hidden">
							<label class="input-label" >传阅：</label>
							
								<p id="refer_wrap" class="input-static address_list">
									{$vo.refer_name}
								</p>
							</div>
						</div>
					</div>
				</div>
				<foreach name="field_list" val="field_vo">
					{:widget('UserDefineField/edit',array($field_vo))}
				</foreach>
				<eq name="flow_type.is_show" value="1">
					<div class="frame">
						<div class="box col-12">
							
								<textarea name="content" class="editor">{$vo.content}</textarea>
							</div>
						</div>
					</div>
				</eq>
				<div class="frame">
					<div class="box col-12">
						
							<label class="input-label" >附件：</label>
							
								{:widget('file_upload/edit',array('add_file'=>$vo['add_file']))}
							</div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</eq>
	<!--审批人不可编辑模板  -->
	<eq name="is_edit" value="0">
		<div class="frame">
			<form method='post' id="form_data" name="form_data" enctype="multipart/form-data"  >
				<input type="hidden" id="ajax" name="ajax" value="0">
				<input type="hidden" id="opmode" name="opmode" value="edit">
				<input type="hidden" id="name" name="name" value="{$vo.name}">
				<input type="hidden" id="id" name="id" value="{$vo.id}">
				<div class="frame">
					<div class="box col-12">
						
							<label class="input-label" >文件编号：</label>
							
								<p class="input-static">
									{$vo.doc_no}
								</p>
							</div>
						</div>
					</div>
					<div class="box col-12">
						
							<label class="input-label" >日期：</label>
							
								<p class="input-static">
									{$vo.create_time|to_date='Y-m-d h:i'}
								</p>
							</div>
						</div>
					</div>
				</div>
				<div class="frame">
					<div class="box col-12">
						<div class="layui-form-item  col-sm-6">
							<label class="input-label" >编写人：</label>
							
								<p class="input-static">
									{$vo.user_name}
								</p>
							</div>
						</div>
					</div>
					<div class="box col-12">
						<div class="layui-form-item  col-sm-6">
							<label class="input-label" >部门：</label>
							
								<p class="input-static">
									{$vo.dept_name}
								</p>
							</div>
						</div>
					</div>
					<div class="frame">
						<div class="box col-12">
							<div class="layui-form-item  col-xs-12">
								<label class="input-label" >审批：</label>
								
									<p id="confirm_wrap" class="input-static">
										{$vo.confirm_name}
									</p>
								</div>
							</div>
						</div>
						<div class="box col-12">
							<div class="layui-form-item col-xs-12">
								<label class="input-label" >协商：</label>
								
									<p id="consult_wrap" class="input-static">
										{$vo.consult_name}
									</p>
								</div>
							</div>
						</div>
					</div>
					<div class="frame">
						<foreach name="field_list" val="field_vo">
							{:widget('UserDefineField/view',array($field_vo))}
						</foreach>
						<eq name="flow_type.is_show" value="1">
							<div class="frame">
								<div class="box col-12">
									<div class="content-wrap">
										{$vo.content}
									</div>
								</div>
							</div>
						</eq>
						<notempty name="vo.add_file">
							
								<label class="input-label" >附件：</label>
								
									{:widget('file_upload/view',array('add_file'=>$vo['add_file']))}
								</div>
							</div>
						</notempty>
					</div>
				</div>
			</form>
		</div>
	</eq>

	<a id="flow_status"></a>
	{:widget('page_header/sub',array('name'=>'审批情况'))}
	<div class="ul-table ul-table_responsive border-bottom">
		<ul>
			<li class="thead">
				<span class="col-6">类型</span>
				<span class="col-9">审批人</span>
				<span class="col-12">日期</span>
				<span class="col-4">结果</span>
				<span class="col-4">附件</span>
				<span class="col-12 x1">意见</span>
			</li>
			<volist name="flow_log" id="item">
				<li class="tbody">
					<span class="col-6">{$item.step|show_step_type}</span>
					<span class="col-9">{$item.user_name}</span>
					<span class="col-12">{$item.update_time|to_date='Y-m-d H:i'}</span>
					<span class="col-4">{$item.result|show_result}</span>
					<eq name="item.log_file" value="">
						<span class="col-5 ">无附件&nbsp;&nbsp;</span>
						<else/>
						<span class="col-5 "><a class="btn-down" add_file="{$item['log_file']}">下载</a>&nbsp;&nbsp;</span>
					</eq>
					<span class="col-12 x1"style="word-wrap:break-word">{$item.comment}</span>
				</li>
			</foreach>
		</ul>
	</div>
	<notempty name="refer_flow_log">
		{:widget('page_header/sub',array('name'=>'参阅情况'))}
		<div class="ul-table">
			<ul>
				<li class="thead">
					<span class="col-12">发送时间</span>
					<span class="col-9">参阅人</span>
					<span class="col-12 x1">参阅人意见</span>
				</li>
				<volist name="refer_flow_log" id="item">
					<li class="tbody">
						<span class="col-9">{$item.from}</span>
						<span class="col-12">{$item.create_time|to_date='Y-m-d H:i'}</span>
						<span class="col-9">{$item.user_name}</span>
						<span class="col-12 x1 "> {$item.comment} </span>
					</li>
				</foreach>
			</ul>
		</div>
	</notempty>
	<notempty name="to_confirm">
		<a id="confirm"></a>
		{:widget('page_header/sub',array('name'=>'审批意见'))}
		<form method="post" action="" name="form_confirm" id="form_confirm">
			<input type="hidden" name="id" value="{$to_confirm.id}">
			<input type="hidden" name="flow_id" value="{$vo.id}">
			<input type="hidden" name="step" value="{$to_confirm.step}">
			<div class="operate-panel">
				<a onclick="go_return_url();" class="btn">返回</a>
				<div class="split"></div>
				<eq name="is_edit" value="1">
					<div class="btn-group">
						<a class="btn btn-warning dropdown-toggle" data-toggle="dropdown" href="#">退回到<span class="fa fa-caret-down"></span> </a>
						<ul class="dropdown-menu col-5">
							<volist name="confirmed" id="item">
								<li onclick="back_to('{$item.emp_no}');">
									<a>{$item.user_name}</a>
								</li>
							</foreach>
							<li onclick="back_to('{$emp_no}');">
								<a>{$user_name}</a>
							</li>
						</ul>
					</div>
				</eq>
				<a onclick="reject();" class="btn btn-del">否决</a>
				<span class="l">|</span>
				<a onclick="approve();" class="btn">同意</a>
				<span class="l">|</span>
				<a onclick="zhuanjiao({$vo.id})" class="btn btn-success">转交</a>
			</div>
			<div class="x-panel-body sub-frame gray" >
				<div class="box col-12">
					
						<label class="input-label" >附件：</label>
						
							{:widget('file_upload/add',array('name'=>'log_file'))}
						</div>
					</div>
				</div>
				<div class="box col-12">
					
						<label class="input-label" >审批意见：</label>
						
							<textarea name="comment" class="simple textarea" style="height:120px"></textarea>
						</div>
					</div>
				</div>

			</div>
		</form>
	</notempty>
	<notempty name="to_refer">
		{:widget('page_header/sub',array('name'=>'参阅人意见'))}
		<form method="post" action="" name="form_confirm" id="form_confirm">
			<input type="hidden" name="id" value="{$to_refer.id}">
			<input type="hidden" name="flow_id" value="{$vo.id}">
			<div class="operate-panel">
				<div class="x-panel-header frame">
					<div class="box col-12">
						<a onclick="go_return_url();" class="btn">返回</a>
					</div>
					<div class="col-12 text-right">
						<a onclick="refer();" class="btn">保存</a>
					</div>
				</div>
				<div class="x-panel-body frame">
					<div class="box col-12">
						
							<label class="input-label" >参阅人意见：</label>
							
								<textarea name="comment" class="textarea" >{$to_refer.comment}</textarea>
							</div>
						</div>
					</div>
				</div>
			</div>
		</form>
	</notempty>
</block>
<block name="js">
	<script type="text/javascript">
		layui.use(['global', 'udf_field', 'editor'], function() {
			var $ = layui.jquery;
			set_return_url();

			$('.btn-down').on('click', function() {
				var add_file = $(this).attr('add_file');
				winopen("{:url('download')}?file=" + add_file, 560, 470);
			});

			$(document).ready(function() {
				$('.address_list').on('mouseenter', 'span', function() {
					$i = $(this).find('i');
					$i.removeClass('fa-arrow-right');
					$i.addClass('fa-times');
				});
				$('.address_list').on('mouseleave', 'span', function() {
					$i = $(this).find('i');
					$i.removeClass('fa-times');
					$i.addClass('fa-arrow-right');

					$(".address_list span i:last").attr('class', 'fa');
				});

				$('.address_list').on('click', 'i', function() {
					$(this).parents('span').remove();
				});
			});
		});

		function approve() {
			send_form("form_confirm", "{:url('approve')}", "{:url('read','id='.$vo['id'])}");
		}

		function refer() {
			send_form("form_confirm", "{:url('refer')}", "{:url('read','id='.$vo['id'])}");
		}

		//转交
		function zhuanjiao(id) {
			winopen("{:url('popup/flow_transfer?id='.$vo['id'],'step='.$to_confirm['step'])}", 560, 470);
		}

		function reject() {
			send_form("form_confirm", "{:url('reject')}", "{:url('read','id='.$vo['id'])}");
		}

		function back_to(emp_no) {
			send_form("form_confirm", fix_url("{:url('back_to')}?emp_no=" + emp_no), "{:url('read','id='.$vo['id'])}");
		}

		function save() {
			$("#confirm").val("");
			$("#confirm_wrap  span").each(function() {
				$("#confirm").val($("#confirm").val() + $(this).attr("data") + '|');
			});
			$("#confirm_name").val($("#confirm_wrap").html());

			$("#consult").val("");
			$("#consult_wrap  span").each(function() {
				$("#consult").val($("#consult").val() + $(this).attr("data") + '|');
			});
			$("#consult_name").val($("#consult_wrap").html());

			$("#refer").val("");
			$("#refer_wrap  span").each(function() {
				$("#refer").val($("#refer").val() + $(this).attr("data") + '|');
			});
			$("#refer_name").val($("#refer_wrap").html());

			if ($("#confirm").val().length < 2) {
				layer.msg('请选择审批流程');
				return false;
			}
			send_form("form_data", "{:url('save')}");
		}

		function popup_confirm() {
			winopen("{:url('popup/confirm')}", 560, 470);
		}

		function popup_refer() {
			winopen("{:url('popup/refer')}", 560, 470);
		}

	</script>
</block>